<template>
  <div>
    <FormDetailNoImg :data-model="[dataModel.detailShowInfo]" />
    <FormDetailNoImg :data-model="[dataModel.checkDeviceShowInfo]" />
    <FormDetailNoImg :data-model="[dataModel.checkOperateShowInfo]" />
    <FormDetailNoImg :data-model="[dataModel.checkItemsShowInfo]" />
  </div>
</template>

<script>
import FormDetailNoImg from '@/components/formEdit/formDetailNoImg'
export default {
  components: { FormDetailNoImg },
  props: ['dataModel'],
  created() {
    console.log('++++++++++++')
    console.log(this.$route.fullPath)
    const id = localStorage.getItem(this.$route.fullPath)
    this.$store
      .dispatch('device_patrol_plan/requestDetailInfo', id)
      .then(res => {
        // 组装展示的数据到结构中
        console.log('查询的巡检详情', res.data)
        // 基础信息
        this.dataModel.detailShowInfo.content.forEach(e => {
          // 把请求的值赋给常量

          if (e.name == 'planPeriodType') {
            e.value = res.data[e.name].toString()
          } else if (e.name == 'dailyPeriod') {
            e.value = res.data[e.name] + ',' + res.data['dailyPeriodType']
          } else {
            e.value = res.data[e.name]
          }
        })
        // 巡检设备
        this.dataModel.checkDeviceShowInfo.tableData =
          [res.data.planRefDevice]
        // 巡检人员,产品改为了表格- -
        this.dataModel.checkOperateShowInfo.tableData = [res.data.userInfo]
        // 巡检项
        this.dataModel.checkItemsShowInfo.tableData = res.data.planItemList
        console.log('巡检详情', this.dataModel)
      })
      .catch(err => {})
  }
}
</script>
